package com.intpro.demo.Controller;

import com.intpro.demo.DAO.Application;
import com.intpro.demo.DAO.CommonRep;
import com.intpro.demo.DAO.User;
import com.intpro.demo.Service.ApplyService;
import com.intpro.demo.Utils.MyAnnotations.Authorization;
import com.intpro.demo.Utils.MyAnnotations.CurrentUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
	@RequestMapping("api/apply")
public class ApplyController
{

	@Autowired
	private ApplyService applyService;

	@Authorization
	@PostMapping
	public CommonRep apply(@CurrentUser User u, @RequestBody Application a)
	{
		a.uid = u.id;
		a.todo = true;
		a.pass = false;
		applyService.addApp(a);
		return new CommonRep();
	}

}
